package sindconsole.auth.service;

import org.springframework.data.domain.Page;
import sindconsole.auth.bean.Account;
import sindconsole.auth.bean.Permission;
import sindconsole.auth.bean.Role;
import sindconsole.auth.bean.User;

import javax.annotation.Nullable;
import java.util.Date;
import java.util.List;
import java.util.Set;

public interface AuthService {

    User findUser(long id);
    Page<User> findUsers(@Nullable String keyword, @Nullable Date createdTime0, @Nullable Date createdTime1, int... pagination);
    int createUser(User user);
    int updateUser(User user);

    Permission findPermission(String key);
    List<Permission> findPermissions();

    Role findRole(String key);
    List<Role> findRoles();
    int createRole(Role role);
    int updateRole(Role role, String oldKey);
    int deleteRole(String key);

    Page<Account> findUserAccount(String keyword, int[] pagination);
    Account findAccount(String username);
    List<Account> findUserAccounts(long id);
    User findUserByUsername(String username);
    User authc(String username, String password);
    User authc(Account account, String password);
    int createAccount(Account account);
    int createUserAndAccount(User user, String username, String password);
    int updateAccount(Account account);
    int updateUserAndPassword(User user, String username, String password);
    int updateUserPassword(long userId, String password);

    List<Permission> findUserPermissions(long id);
    Set<String> findUserPermissionKeys(long id);
    Set<String> findAllUserPermissionKeys(long id);
    int giveUserPermissions(long id, String... permissionKeys);
    int ungiveUserPermissions(long id, String... permissionKeys);

    List<Role> findUserRoles(long id);
    Set<String> findUserRoleKeys(long id);
    int giveUserRoles(long id, String... roleKeys);
    int ungiveUserRoles(long id, String... roleKeys);

    List<Permission> findRolePermission(String key);
    Set<String> findRolePermissionKeys(String key);
    int giveRolePermissions(String key, String... permissionKeys);
    int ungiveRolePermissions(String key, String... permissionKeys);


}
